﻿//==================================================================
// Copyright (C) 2011 深圳市中旭企业管理股份有限公司
// 作 者：曾洋
// 日 期：2012-1-4 16:11:29
// 描 述：
// 版 本：1.00
// 修改历史纪录
// 版 本  修改时间      修改人            修改内容
// 1.00             
//==================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using ZX.CRM.Bussiness;
using ZX.CRM.Library;
using ZX.EHR.Library;
using ZX.Web.UI.Controls;
using ZX.Common;
using ZX.BLL;
using ZX.DBModule;
using System.Text.RegularExpressions;
using System.Text;
using System.Data;
using System.Web.UI.WebControls;
using ZX.TR.Bussiness;
using ZX.TR.Library;

namespace ZX.WebApp.Crm.Customer
{
    public partial class ShareCustomer : BasePage
    {
        #region   全局变量
        BTCrmCustomer tsC = new BTCrmCustomer();
        BTrQuestionnaireSubject ts = new BTrQuestionnaireSubject();
        #endregion
        #region 页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            DatUser du = Session["User"] as DatUser;
            if (du != null)
            {
                string strEntity = this.GetStringFromQueryString("entity", "");
                string ShareCrmId = this.Request.QueryString["id"] == null ? "00000000-0000-0000-0000-000000000000" : Request.QueryString["id"];
                this.hiddenId.Value = ShareCrmId;
                this.hdnUid.Value = this.UserId.ToString();
                string strName = this.GetStringFromQueryString("n", "");
                string strDecisioner = this.GetStringFromQueryString("m", "");
                string strCode = this.GetStringFromQueryString("code", "");
                string strType = this.GetStringFromQueryString("type", "");
                if (strName == "" || strDecisioner == "" || strCode == "")
                {
                    V_CrmPrivateCustom tq = tsC.GetCrmShareInfo(new Guid(ShareCrmId));
                    if (tq != null)
                    {
                        this.txtName.Text = tq.CustomerName;
                        this.txtDecisionName.Text = tq.Decisionmaker;
                        this.txtCode.Text = tq.Code;
                    }
                    else
                    {
                        this.txtName.Text = strName;
                        this.txtDecisionName.Text = strDecisioner;
                        this.txtCode.Text = strCode;
                    }
                    this.hiddenType.Value = "0";
                    this.hiddenEntity.Value = strEntity;
                }
                else if (strName == "1" && strDecisioner == "1" && strCode == "1")
                {
                    this.lblCode.Visible = false;
                    this.txtCode.Visible = false;
                    this.lblName.Visible = false;
                    this.txtName.Visible = false;
                    this.lblDecisionName.Visible = false;
                    this.txtDecisionName.Visible = false;
                    this.lblTitle.Text = " - 批量分配";
                    this.hiddenType.Value = "1";
                    this.hiddenEntity.Value = strEntity;
                }
                else
                {
                    this.txtName.Text = strName;
                    this.txtDecisionName.Text = strDecisioner;
                    this.txtCode.Text = strCode;
                    this.hiddenType.Value = "1";
                    this.hiddenEntity.Value = strEntity;
                }
                if (strType == "1") //客户共享
                {
                    IList<DatUser> listEmployees = null;
                    listEmployees = ts.GetUserNameByFCId(du.UserID, new Guid(ShareCrmId));
                    if (listEmployees != null && listEmployees.Count > 0)
                    {
                        for (int i = 0; i < listEmployees.Count; i++)
                        {
                            this.lstBoxResult.Items.Add(new ListItem(listEmployees[i].UName, listEmployees[i].UserID.ToString()));
                        }
                    }
                    else
                    {
                        this.lstBoxResult.Items.Clear();
                    }
                }
            }
        }
        #endregion
    }
}